// 基于准备好的dom，初始化echarts实例
var monthChart = echarts.init(document.querySelector(".month-graph"))

// 指定图表的配置项和数据
var monthOption = {
	title: {
		text: "曲线图数据展示",
		textAlign: "center",
		top: "auto",
		left: "50%",
		right: "50%",
		padding: [24, 0, 0, 0],
	},
	xAxis: {
		type: "category",
		boundaryGap: false,
		data: [],
	},
	yAxis: {
		type: "value",
		axisLabel: {
			formatter: `{value} 人`,
		},
	},
	series: [
		{
			type: "line",
			smooth: true,
			data: [],
			areaStyle: {
				color: "rgba(65,132,243,.2)",
			},
			lineStyle: {
				color: "rgba(65,132,243,1)",
			},
			label: { show: true, position: "top",color:"rgba(65,132,243,1)" },
		},
	],
}

getData({ type: "month" }).then((res) => {
	let xAxisData = res.data.data.xAxis
	let seriesData = res.data.data.series
	this.monthOption.xAxis.data = xAxisData.filter((item, index) => index % 2 === 0)
	this.monthOption.series[0].data = seriesData.filter(
		(item, index) => index % 2 === 0
	)
	monthChart.setOption(monthOption)
})
